﻿using Dm.util;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataCollection.Core.Models
{
    /// <summary>
    /// 界面点位
    ///</summary>
    [SugarTable("c_form_point")]
    public class FormPointModel
    {
        #region 属性
        /// <summary>
        /// 备  注:界面点位编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "number", IsPrimaryKey = true)]
        public long Number { get; set; }

        /// <summary>
        /// 备  注:界面点位名称
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "name")]
        public string Name { get; set; } = null!;

        /// <summary>
        /// 备  注:设备编号
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "device_point_number")]
        public long DevicePointNumber { get; set; }

        /// <summary>
        /// 备  注:界面控件名称
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "form_control_name")]
        public string FormControlName { get; set; } = null!;

        /// <summary>
        /// 备  注:转换方法
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "conver")]
        public string Conver { get; set; } = null!;

        /// <summary>
        /// 备  注:界面变量
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "variable")]
        public string Variable { get; set; } = null!;

        /// <summary>
        /// 备  注:可用
        /// 默认值:
        ///</summary>
        [SugarColumn(ColumnName = "enable")]
        public int Enable { get; set; }

        #endregion

        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        public int Add()
        {
            List<FormPointModel> list = new List<FormPointModel>();
            list.Add(this);
            int res = SqlSugarHelper.Insertable<FormPointModel>(list);
            return res;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        public int Delete()
        {
            List<FormPointModel> list = new List<FormPointModel>();
            list.Add(this);
            int res = SqlSugarHelper.Deleteable<FormPointModel>(list);
            return res;
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <returns></returns>
        public int Update()
        {
            List<FormPointModel> list = new List<FormPointModel>();
            list.Add(this);
            int res = SqlSugarHelper.Updateable<FormPointModel>(list);
            return res;
        }

        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>

        public static List<FormPointModel> List(Dictionary<string, object> where)
        {

            return SqlSugarHelper.Inquireable<FormPointModel>(where);
        }
    }
}
